C     COPYRIGHT       NONE.  THIS CODE IS IN THE PUBLIC DOMAIN.
C     FILENAME        GEMINICATCHUPANDRENDEZVOUSPROGRAM/STATE.F
C     PURPOSE         THIS IS THE POSITION INTEGRATION SUBROUTINE
C		      OF THE ORIGINAL 1965 SIMULATION
C                     PROGRAM FOR THE GEMINI 7/6 MISSION
C                     CATCH-UP AND RENDEZVOUS FLIGHT PHASES.
C                     THIS PARTICULAR FILE CONTAINS ONLY THE
C                     STATE SUBROUTINE.
C     WEBSITE         WWW.IBIBLIO.ORG/APOLLO
C     HISTORY         2010-08-14 RSB  BEGAN TRANSCRIBING FROM
C                                     THE SCANNED PDF REPORT.
C
C     REFER TO MAIN.F FOR MORE-DETAILED INTRODUCTORY COMMENTS.
C
C     FROM PAGE 152 OF THE REPORT 
      SUBROUTINE STATE (W)
CSTATE     IBM-OWEGO, SINGLE-PRECISION COWELLS METHOD, (3) SCARBOROUGH
C
C      14 ARGUMENTS ARE REQUIRED FOR THIS SUBROUTINE.
C     THEY ARE AS FOLLOWS,
C        ARG1=X POSITION COMPONENT
C        ARG2=Y POSITION COMPONENT
C        ARG3=Z POSITION COMPONENT
C        ARG4=RADIUS MAGNITUDE
C        ARG5=X VELOCITY COMPONENT
C        ARG6=Y VELOCITY COMPONENT
C        ARG7=Z VELOCITY COMPONENT
C        ARG8=VELOCITY MAGNITUDE
C        ARG9=EARTH OBLATENESS CONSTANT, RJ
C        ARG10=TIME STEP SIZE
C        ARG11=X THRUST ACCELERATION
C        ARG12=Y THRUST ACCELERATION
C        ARG13=Z THRUST ACCELERATION
C        ARG14=NOT USED
C     ALL ARGUMENTS EXCEPT VELOCITY MAGNITUDE AND ARG14 MUST BE
C     INITIALLY SUPPLIED
C
      DIMENSION W(14),R(14)
      DO 1  I=1,14
1     R(I)=W(I)
3     DO 10 I=1,3
2     G=-.1407654E17/R(4)**3
      Q3=R(9)*(2.0925874E7/R(4))**2
      Q4=5.*(R(3)/R(4))**2
      Q1=1.+Q3*(1.-Q4)
      XDD=+G*R(1)*Q1+R(11)
      YDD=+G*R(2)*Q1+R(12)
      ZDD=+G*R(3)*(1.+Q3*(3.-Q4))+R(13)
      GO TO (4,5,6),I
4     XP=R(1)
      YP=R(2)
      ZP=R(3)
      XK1=XDD
      YK1=YDD
      ZK1=ZDD
      T1=R(10)/2.
      T2=R(10)**2/8.
      R(1)=XP+T1*R(5)+T2*XDD
      R(2)=YP+T1*R(6)+T2*YDD
      R(3)=ZP+T1*R(7)+T2*ZDD
      R(4)=SQRTF(R(1)**2+R(2)**2+R(3)**2)
      GO TO 10
5     T1=T2*4.
      R(1)=XP+R(10)*R(5)+T1*XDD
      R(2)=YP+R(10)*R(6)+T1*YDD
      R(3)=ZP+R(10)*R(7)+T1*ZDD
      R(4)=SQRTF(R(1)**2+R(2)**2+R(3)**2)
      XK2=XDD
      YK2=YDD
      ZK2=ZDD
      GO TO 10
C
C     FROM PAGE 153 OF THE REPORT 
6     T1=R(10)/6.
      R(1)=XP+R(10)*(R(5)+T1*(XK1+2.*XK2))
      R(2)=YP+R(10)*(R(6)+T1*(YK1+2.*YK2))
      R(3)=ZP+R(10)*(R(7)+T1*(ZK1+2.*ZK2))
      R(4)=SQRTF(R(1)**2+R(2)**2+R(3)**2)
      R(5)=R(5)+T1*(XK1+4.*XK2+XDD)
      R(6)=R(6)+T1*(YK1+4.*YK2+YDD)
      R(7)=R(7)+T1*(ZK1+4.*ZK2+ZDD)
      R(8)=SQRTF(R(5)**2+R(6)**2+R(7)**2)
10    CONTINUE
      DO 20  I=1,14
20    W(I)=R(I)
      RETURN
      END(1,1,0,0,0,0,1,1,0,0,0,0,0,0,0)
